package chpt09;

public class FirstThread extends Thread { 
	@Override
	public void run() {
		String name = this.getName();  // 获取线程名
		try {
			Thread.sleep(500);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(name+"线程结束!");
	}
	public static void main(String[] args) {
		Thread t1 = new FirstThread(); // 创建Thread对象
		t1.setName("线程1");
		t1.start(); // 启动线程t1
		String name = Thread.currentThread().getName(); // 获取当前线程名
		System.out.println("主线程"+name+"结束!");
	}
}
